FROM {{ namespace }}/{{ image_prefix }}ironic-base:{{ tag }}
{% block labels %}
LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
{% endblock %}

{% block ironic_pxe_header %}{% endblock %}

{% import "macros.j2" as macros with context %}

{% if base_package_type == 'rpm' %}
    {% set ironic_pxe_packages = [
        'grub2-tools',
        'grub2-efi-*64',
        'grub2-efi-aa64-modules',
        'ipxe-bootimgs',
        'shim-*64',
        'tftp-server',
    ] %}

    {% if base_arch in ['x86_64'] %}
        {% set ironic_pxe_packages = ironic_pxe_packages + [
            'syslinux-tftpboot'
        ] %}
    {% endif %}

{{ macros.install_packages(ironic_pxe_packages | customizable("packages")) }}
{% elif base_package_type == 'deb' %}
    {% set ironic_pxe_packages = [
        'grub-efi-*64-signed',
        'ipxe',
        'pxelinux',
        'shim-signed',
        'syslinux-common',
        'tftpd-hpa'
    ] %}

    {% if base_arch == 'x86_64' %}
        {% set ironic_pxe_packages = ironic_pxe_packages + [
            'syslinux'
        ] %}
    {% endif %}

{{ macros.install_packages(ironic_pxe_packages | customizable("packages")) }}
{% endif %}

ENV TFTPBOOT_PATH=/tftpboot \
    HTTPBOOT_PATH=/httpboot
COPY tftp-map-file-template /map-file-template
COPY extend_start.sh /usr/local/bin/kolla_ironic_extend_start
RUN chmod 644 /usr/local/bin/kolla_ironic_extend_start

{% block ironic_pxe_footer %}{% endblock %}
{% block footer %}{% endblock %}
